#pragma once

#include "base_types.h"
#include <string>

// Global configuration
struct GlobalConfig {
    static const int DEFAULT_HTTP_PORT = 8080;
    static const int DEFAULT_BACKLOG = 128;
    static const int DEFAULT_TIMEOUT = 30000; // 30 seconds
    static const int MAX_BUFFER_SIZE = 8192;
    static const int MAX_CONNECTIONS = 10000;
    
    // HTTP settings
    static const int HTTP_KEEP_ALIVE_TIMEOUT = 60; // seconds
    static const int HTTP_MAX_REQUEST_SIZE = 8192;
    static const int HTTP_MAX_RESPONSE_SIZE = 65536;
    
    // Timer settings
    static const int TIMER_CHECK_INTERVAL = 100; // milliseconds
};

// Global utility functions
namespace GlobalUtils {
    // String utilities
    std::string Trim(const std::string& str);
    std::string ToLower(const std::string& str);
    std::string ToUpper(const std::string& str);
    bool StartsWith(const std::string& str, const std::string& prefix);
    bool EndsWith(const std::string& str, const std::string& suffix);
    
    // Time utilities
    int64_t GetCurrentTimeMillis();
    std::string FormatTime(time_t time, const std::string& format);
    
    // Error handling
    const char* GetErrorString(int error_code);
    void LogError(const std::string& message);
    void LogWarning(const std::string& message);
    void LogNotice(const std::string& message);
    void LogInfo(const std::string& message);
    void LogDebug(const std::string& message);
}

// Global variables
extern bool g_shutdown_requested;
extern int g_log_level;